package com.skstudio.reportview;

import java.util.ArrayList;
import com.skstudio.report.ReportCpu;
import com.skstudio.report.ReportCpu.DataCpu;
import com.skstudio.report.SpyData;

public class ReporterSysCpu extends ReportViewController {

    ReportCpu mCpu = null;

    @Override
    public void setSpyData(SpyData ref) {
        super.setSpyData(ref);
        mCpu = ref.getReportCpu();
    }

    @Override
    public int getReportRows() {
        return 2;
    }

    @Override
    public int getReportColumns() {
        if (mCpu.mDataList.size() > 0) {
            return mCpu.mDataList.get(0).size();
        }
        return 0;
    }

    @Override
    public int getEntry(int row, int col) {
        if (mCpu.mDataList.size() > row) {
            ArrayList<DataCpu> list = mCpu.mDataList.get(0);
            if (list.size() > col) {
                switch (row) {
                    case 0:
                        return (int) (list.get(col).getTotalUsage());
                    case 1:
                        return (int) (list.get(col).mKernelPctage);
                }
            }
            return 0;
        }
        return 0;
    }

    @Override
    public String getReportDescription() {
        return "Total CPU Usage";
    }

    @Override
    public String getEntryName(int row) {
        switch (row) {
            case 0:
                return "System wide CPU load includes time spent on use mode, kernel mode, and servcing interrupts";
            case 1:
                return "System wide CPU load on kernel mode, and servcing interrupts\n";
        }
        return null;
    }
}
